	<?php echo validation_errors('<p class="error">', '</p>'); ?>
    	<?php 
		$attributes = array('class' => 'form_input', 'id' => '');
		$hidden = array('user_send'=>$this->current_user->id,'parent_id'=>isset($parent_id) ? $parent_id : 0,'room_id'=>$room_id);
		//if($model['id']){
		//$hidden = array('id' => $model['id']);
		//}
		echo form_open('',$attributes,$hidden) ?>
			
			<!--<input type="text" name="title" class="txt medium" id="title" value="<?php echo $model['title']?>" />-->
        	<!--<input type="hidden" value="<?php echo $model['id'] ?>" name="id" id="id" />-->
                	<div class="input"><?php 
						$data = array('name'=>'title','id'=>'title','value'=> $model['title'],'maxlength'=>255,'class'=>'txt medium','placeholder'=>lang('project:title'));
						echo form_input($data);?></div>
					<div class="input">
					<?php 
					echo form_dropdown('user_receive[]',$employees_select,'','multiple class="chosen inHoa medium" data-placeholder = "'.lang('project:user_receive').'" ')
					?>
					</div>
					<div class="input">
					{{helper:lang line = 'project:priority' }}
					<input type="hidden" value="" name="priority_id" id="priority_id" />
					</div>
					<div class="input">
						<div class="priority_slider" style="width:40%"></div>
					</div>
					
					<div  class="input">
					<input type="hidden" class="txt small" name="date_start" id="date_start" value="{{helper:date format = 'd-m-Y'}}<?php //echo $model['date_start']?>" placeholder="{{helper:lang line='project:date_start'}}" />
					<input type="hidden" class="txt small" name="date_end" id="date_end" value="{{helper:date format = 'd-m-Y'}}<?php //echo $model['date_end']?>"  placeholder="{{helper:lang line='project:date_end'}}" />
					</div>
                	 <div  class="input">
                 	<?php 
						$data = array('name'=>'description','id'=>'description','value'=> $model['description'],'class'=>'editor large', 'rows'=>10,'cols'=>80);
						echo form_textarea($data) ?>
                    </div>
     {{ theme:partial name="_form_button" }}			
<?php echo form_close() ?>    


<script type="text/javascript">
/*
CKEDITOR.replace( 'description',{
	//uiColor : '#0072C6',
	toolbar :[
		['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink'],
		['About','-','Abbr',''],['TextColor','BGColor']
	]
});
*/
CKEDITOR.config.toolbar = [
   ['Styles','Format','Font','FontSize'],
   //'/',
   ['Bold','Italic','Underline','StrikeThrough','-','Undo','Redo','-','Cut','Copy','Paste','Find','Replace','-','Outdent','Indent','-','Print'],
   ['NumberedList','BulletedList','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']
   //['Image','Table','-','Link','Flash','Smiley','TextColor','BGColor','Source']
] ;
CKEDITOR.replaceClass = 'editor';
//$('.chosen').chosen();
$(".chosen").chosen({
	//display_selected_options:true,
	no_results_text: "Oops, nothing found!",
	disable_search_threshold: 10
}); 
<?php if(isset($model['user_receive'])){?>
var json = <?php echo json_encode($model['user_receive']);?>;
$('select.chosen').val(json);
$('select.chosen').trigger('liszt:updated');
<?php } ?>

</script>
<a class="btn btn2 prev-date">{{helper:lang line='project:prev'}}</a>
<a class="btn btn2 next-date">{{helper:lang line='project:next'}}</a>
<a class="btn btn2 today">{{helper:lang line='project:today'}}</a>
<div id='calendar'></div>
<div class="dialog" style="display:none;">
	
</div>
<script>
//muc do uu tien
//background_slider( $( ".priority_slider" ),1);
$(function() {
    $( ".priority_slider" ).slider({
      range: "min",
      min: 0,
      max: 2,
      value: 0,
      slide: function( event, ui ) {
        $( "#priority_id" ).val( ui.value );
		background_slider( $( ".priority_slider" ),ui.value);
      }
    });
    $( "#priority_id" ).val( $( ".priority_slider" ).slider( "value" ) );
	background_slider( $( ".priority_slider" ),0);
  });
function background_slider($slider,$value){
	$color = "";
	if($value == 0)
		$color = '#82BA00';
	if($value == 1)
		$color = '#2bc252';
	//if($value == 2)
		//$color = '#f7995b';
	if($value == 2)
		$color = '#db3e3e';
	$slider.find('.ui-slider-range').css('background-color',$color);
	$slider.find('.ui-slider-handle').css('border-color',$color);
}

var value_date = {};
var ajax_month;
var month;
var calendar;
//CALENDAR
//.fullCalendar( 'removeEvent', id )
//$('#calendar').fullCalendar('next');
//$('#calendar').fullCalendar('prev');
//$('#calendar').fullCalendar("today")
	$(document).ready(function() {
		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		calendar = $('#calendar').fullCalendar({
			header: {
				//left: 'prev,next, today',
				left:false,
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			dayNamesShort:['CN','T2','T3','T4','T5','T6','T7'],
			timeFormat: {
			agenda: 'h(:mm)t{ - h(:mm)t}',
			'': 'h(:mm)t{-h(:mm)t }'
		   },
		   columnFormat: {
            month: 'ddd',
            week: 'ddd d/M',
            day: 'dddd d/M'
			},
			buttonText: {
			//today: '{{helper:lang line="project:today"}}',
			month: '{{helper:lang line="project:month"}}',
			week: '{{helper:lang line="project:week"}}',
			day: '{{helper:lang line="project:day"}}'
		   },
		   monthNames: ["{{helper:lang line='project:month1'}} - ","{{helper:lang line='project:month2'}}",
						"{{helper:lang line='project:month3'}}","{{helper:lang line='project:month4'}}",
						"{{helper:lang line='project:month5'}}","{{helper:lang line='project:month6'}}",
						"{{helper:lang line='project:month7'}}", "{{helper:lang line='project:month8'}}", 
						"{{helper:lang line='project:month9'}}", "{{helper:lang line='project:month10'}}",
						"{{helper:lang line='project:month11'}}", "{{helper:lang line='project:month12'}}" ],
		   weekends: true,
			disableDragging: true,
			eventClick : function (event){
					if (event.url) {
					window.open(event.url);
					return false;
				}
				//alert(event.description);
				var dialog = $('.dialog');
				dialog.html('');
				$html = "";
				$('.dialog').append('<p>{{helper:lang line="project:percent"}}: '+event.percent+' % </p>');
				$('.dialog').append('<div class="slider"></div>');//'+event.percent+'
				$('.dialog').append('<h3>{{helper:lang line="project:user_receive"}}</h3>');
				$.each(event.users,function(v,a){
					//alert(a.display_name);
					$html += '<div class="inHoa">'+a.display_name;
					$checked = "";
					if(a.important == 1)
							$checked = 'checked = "checked"';
					$html += '<input '+$checked+' type="radio" name="important" value="'+a.user_id+'" />';
					$html += '</div>';
				});
				$('.dialog').append($html);
				$('.dialog').dialog({
					title:event.title,
					width:500,
					open:function(){
						$('.slider').slider({
							//range: true,
							step:5,
							//change: true,
							slide: function(event, ui){
								return false;
								//alert(ui.value);
								//alert(val(ui.value));
								//$("."+ txtmax).val(ui.values[ 1 ]);
							},
							value:event.percent
						});
					},
					modal:true
				});
			},
			selectable: true,
			selectHelper: true,
			
			/*select: function(start, end, allDay) {
				var title = prompt('{{helper:lang line="project:title"}}:');
				value_date.title = title;
				
				if (title) {
					
					value_date.start = $.datepicker.formatDate('yy-mm-dd', new Date(start));
					value_date.end = $.datepicker.formatDate('yy-mm-dd', new Date(end));
					value_date.allDay = allDay;
					$('#date_start').val(value_date.start);
					$('#date_end').val(value_date.end);
					$('#title').val(title);
					calendar.fullCalendar('renderEvent',
						{
							title: title,
							start: start,
							end: end,
							allDay: allDay
						},
						true // make the event "stick"
					);
				}
				calendar.fullCalendar('unselect');
			},*/
			
			editable: true,
			events: function(start, end, callback) {
				month = $('#calendar').fullCalendar('getDate');
				$month_start = $.datepicker.formatDate('yy-mm', new Date(month));
				$room_id = $('.form_input input[name="room_id"]').val();
			   if(ajax_month != null)
					ajax_month.abort();
				ajax_month = $.ajax({
					url:'{{url:site uri="business/get_month"}}',
					data:{date:$month_start,room_id2:$room_id},
					type:'post',
					dataType:'json',
					success:function(json_data){
						var events = [];
						$.each(json_data,function(v,a) {
							if(!a.type){
							
							events.push({
								title: a.title,
								description : a.description,
								percent : a.percent,
								status : a.status,
								users : a.users,
								//user_
								start: new Date(a.start), // will be parsed
								//url:'google.com',
								end: new Date(a.end)
							});
							}
							else{
								events.push({
									title: a.title,
									type: a.type,
									date_date: a.date_date,
									className : 'off',
									start: new Date(a.start)
									
								});
							}
							
						});
						
						/*$test = {
								title: 'Long Event',
								start: new Date(2013, 9, 14),
								end: new Date(2013, 9, 17)
						};
						events.push($test);*/
						callback(events);
					}
				});//ajax
				/*[
				{
					title: 'All Day Event',
					start: new Date(y, m, 1)
				}
				]*/
			},
			
			eventRender : function (event , element) {
				if(event.type){
					if(event.type == 'off'){
						$('.fc-day[data-date="' + event.date_date + '"]').css('background', '#EE7F13');
					}
				}
				
			}
			/*[
				{
					title: 'All Day Event',
					start: new Date(y, m, 1)
				},
				{
					title: 'Long Event',
					start: new Date(y, m, d-5),
					end: new Date(y, m, d-2)
				},
				{
					id: 999,
					title: 'Repeating Event',
					start: new Date(y, m, d-3, 16, 0),
					allDay: false
				},
				{
					id: 999,
					title: 'Repeating Event',
					start: new Date(y, m, d+4, 16, 0),
					allDay: false
				},
				{
					title: 'Meeting',
					start: new Date(y, m, d, 10, 30),
					allDay: false
				},
				{
					title: 'Lunch',
					start: new Date(y, m, d, 12, 0),
					end: new Date(y, m, d, 14, 0),
					allDay: false
				},
				{
					title: 'Birthday Party',
					start: new Date(y, m, d+1, 19, 0),
					end: new Date(y, m, d+1, 22, 30),
					allDay: false
				},
				{
					title: 'Click for Google',
					start: new Date(y, m, 28),
					end: new Date(y, m, 29),
					url: 'http://google.com/'
				}
			]*/
		});
		
	
		
		//xu ly cua tui
		
		$('a.prev-date').click(function(){
			$('#calendar').fullCalendar('prev');
			//get_project_in_month();
			
		});
		$('a.next-date').click(function(){
			$('#calendar').fullCalendar('next');
			//get_project_in_month();			
		});
		$('a.today').click(function(){
			$('#calendar').fullCalendar("today");
		});
		
		
		//end xu ly cua tui
		//calendar.fullCalendar("removeEvents", function (event) {
			
			//return event.id == calEvent.Id;
		//});
	});

function get_project_in_month(){
	month = $('#calendar').fullCalendar('getDate');
			$month_start = $.datepicker.formatDate('yy-mm', new Date(month));
		   if(ajax_month != null)
				ajax_month.abort();
			ajax_month = $.ajax({
				url:'{{url:site uri="business/get_month"}}',
				data:{date:$month_start},
				type:'post',
				dataType:'json',
				success:function(json_data){
					
				}
			});//ajax
}
function test_get_project_in_month(){
		month = $('#calendar').fullCalendar('getDate');
			$month_start = $.datepicker.formatDate('yy-mm', new Date(month));
			
		   if(ajax_month != null)
				ajax_month.abort();
			ajax_month = $.ajax({
				url:'{{url:site uri="business/get_month"}}',
				data:{date:$month_start},
				type:'post',
				dataType:'json',
				success:function(json_data){
					var events = eval(json_data);
                    callback(events);
				}
			});//ajax
}
</script>

<!--
eventClick: function(event){
  var event_id = event.id;
  $.post('/Dropbox/finance/index.php/welcome/update', {"event_id": event_id},
      function(data){
          $('#calendar').fullCalendar("removeEvents",  (data));
          $('#calendar').fullCalendar("rerenderEvents");                
        }
      });   
}
-->